// 通用类型定义

export interface ApiResponse<T = any> {
  success: boolean;
  data?: T;
  message?: string;
  error?: string;
}

export interface PaginationParams {
  page?: number;
  limit?: number;
  skip?: number;
}

export interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  size: number;
  hasNext?: boolean;
  hasPrevious?: boolean;
}

export interface BaseEntity {
  id: number;
  created_at: string;
  updated_at: string;
}

// 用户相关类型
export interface User extends BaseEntity {
  username: string;
  email: string;
  is_active: boolean;
  is_superuser: boolean;
  last_login_at?: string;
  roles?: Role[];
  permissions?: Permission[];
}

export interface Role extends BaseEntity {
  name: string;
  description?: string;
  is_active: boolean;
  permissions?: Permission[];
}

export interface Permission extends BaseEntity {
  name: string;
  description?: string;
  resource: string;
  action: string;
}

// LLM 相关类型
export interface LLMModel extends BaseEntity {
  name: string;
  provider: string;
  llm_model_id: string;
  max_tokens: number;
  temperature: number;
  is_active: boolean;
}

export interface LLMProvider {
  provider: string;
  name: string;
  description: string;
  models: string[];
  is_available: boolean;
}

export interface Conversation extends BaseEntity {
  user_id: number;
  title: string;
  llm_model_id: number;
  llm_model_name: string;
  provider: string;
  is_active: boolean;
  message_count: number;
}

export interface ChatMessage extends BaseEntity {
  conversation_id: number;
  role: 'user' | 'assistant';
  content: string;
}

// 热点数据相关类型
export interface HotPlatform {
  name: string;
  platform_name: string;
  type: string;
  description: string;
  available: boolean;
}

export interface HotItem {
  index: number;
  title: string;
  url: string;
  hot?: string | number;
  desc?: string;
  pic?: string;
  timestamp?: string;
}

export interface HotData {
  platform: string;
  subtitle: string;
  update_time: string;
  data: HotItem[];
}

// 通用 UI 状态类型
export interface LoadingState {
  isLoading: boolean;
  error: string | null;
}

export interface AsyncState<T> extends LoadingState {
  data: T | null;
}

// 表单相关类型
export interface FormState<T> {
  values: T;
  errors: Partial<Record<keyof T, string>>;
  isSubmitting: boolean;
  isValid: boolean;
}

// 模态框状态类型
export interface ModalState {
  isOpen: boolean;
  title?: string;
  content?: React.ReactNode;
  onConfirm?: () => void;
  onCancel?: () => void;
}

// 通知消息类型
export interface NotificationMessage {
  id: string;
  type: 'success' | 'error' | 'warning' | 'info';
  title: string;
  content?: string;
  duration?: number;
  timestamp: number;
}

// 路由相关类型
export interface RouteConfig {
  path: string;
  component: React.ComponentType;
  exact?: boolean;
  requireAuth?: boolean;
  requireAdmin?: boolean;
  title?: string;
  icon?: string;
}

// 菜单项类型
export interface MenuItem {
  key: string;
  label: string;
  icon?: React.ReactNode;
  path?: string;
  children?: MenuItem[];
  requireAuth?: boolean;
  requirePermission?: string;
}

export * from './crawler';
export * from './components';
